#include<bits/stdc++.h>
#define fi first
#define int long long
#define se second
using namespace std;
int T;
int n,m,L,V;
int shu[200000];
int vis[200000];
vector<int> va[200000];
vector<int> vv[200000];
int p[200000];
int q[200000];
int check(int che)
{
    int suc=1;
    for(int i=1;i<=m;i++)q[i]=p[i]-vv[che][0];
    for(int i=1;i<=m;i++)
    {
        if(vis[i]==0&&q[i]>=0&&vv[che][1]*vv[che][1]+2*vv[che][2]*q[i]>V*V)
        {
            suc=0;
        }
    }
    return suc;
}
signed main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);

    cin>>T;
    for(int ii=1;ii<=T;ii++)
    {
        int sum=0;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++)vv[i].clear();
        for(int i=1;i<=n;i++)
        {
            int d,v,a;
            cin>>d>>v>>a;
            vv[i].push_back(d);
            vv[i].push_back(v);
            vv[i].push_back(a);
        }
        for(int i=1;i<=m;i++)
        {
            cin>>p[i];
        }
        for(int i=1;i<=n;i++)
        {
            if(check(i)==0)sum++;
        }
        int guan=0;
        for(int i=1;i<=m;i++)
        {
            vis[i]=1;
            int sun=0;
            for(int j=1;j<=n;j++)
            {
                if(check(j)==0)sun++;
            }
            if(sum==sun)guan++;
            vis[i]=0;
        }
        cout<<sum<<" "<<guan<<"\n";
    }
    return 0;
}
